package br.senai.servlet;

import java.io.IOException;

import javax.servlet.RequestDispatcher;
import javax.servlet.ServletException;
import javax.servlet.http.HttpServlet;
import javax.servlet.http.HttpServletRequest;
import javax.servlet.http.HttpServletResponse;

import br.com.senai.Contato;

public class BuscaContatos extends HttpServlet{

	@Override
	public void doGet(HttpServletRequest req, HttpServletResponse resp)
			throws ServletException, IOException {
		doGet(req, resp);
	}

	@Override
	public void doPost(HttpServletRequest req, HttpServletResponse resp)
			throws ServletException, IOException {
		doPost(req, resp);
	}
	
	public void doAction(HttpServletRequest req, HttpServletResponse resp)
			throws ServletException, IOException{
		Contato[] contatos=new Contato[2];
		
		Contato c0=new Contato("Rodrigo","meu endereco","rodrigo.candido@email.com");
		Contato c1=new Contato("Tinga","endereco do Tinga","tinga.nei@email.com");
		
		contatos[0]=c0;
		contatos[1]=c1;
		
		req.setAttribute("ctos", contatos);
		RequestDispatcher rd=req.getRequestDispatcher("/listaContatos.jsp");
		rd.forward(req, resp);
	}

}
